package com.cg.design.graphicdesignpattern.prototype;

import com.cg.design.graphicdesignpattern.prototype.framework.Manager;
import com.cg.design.graphicdesignpattern.prototype.framework.Product;
import org.junit.Test;

/**
 * 原型模式测试类
 *
 * @program: LeetCode->PrototypeTest
 * @description: 原型模式测试类
 * @author: cg
 * @create: 2022-03-20 16:04
 **/
public class PrototypeTest {

    @Test
    public void testPrototype() {
        Manager manager = new Manager();
        UnderlinePen underlinePen = new UnderlinePen('~');
        MessageBox box1 = new MessageBox('*');
        MessageBox box2 = new MessageBox('/');
        manager.register("strong message", underlinePen);
        manager.register("warning box", box1);
        manager.register("slash box", box2);

        Product p1 = manager.create("strong message");
        p1.use("Hello, world.");
        Product p2 = manager.create("warning box");
        p2.use("Hello, word.");
        Product p3 = manager.create("slash box");
        p3.use("Hello, word.");
    }

}
